Media player instance managed resource reduction

ABSTRACT

Techniques and systems are disclosed for managing computer resources available to multiple running instances of a media player program. The methods include monitoring consumption of computing resources of multiple running instances of a media player program to render respective media content in a graphical user interface of a computing device. The graphical user interface associated with an additional program configured to render additional content, different from the media content, to the graphical user interface. The additional program can be a browser. The methods further include instructing the multiple instances to reduce respective portions of the computing resources consumption upon determining that a requested increase in computer resources consumption of the media player program would cause the computer resources consumption of the media player program to exceed a first predetermined level.

BACKGROUND

This specification relates to managing computing resources consumed by amedia player program, and specifically to reducing the media playerprogram's resources when necessary by instructing individual playerinstances to reduce resources or to shut down based on a specifiedpriority.

A web browser is a software program for retrieving and presentinginformation resources on the World Wide Web. An information resource istypically identified by a Uniform Resource Locator (URL) and may be aweb page, image, video, or other piece of content. Hyperlinks present inresources enable users to easily navigate their browsers to relatedresources. Aside from HTML, browser programs can generally display anykind of content that can be part of a web page. Most browser programscan display images, audio, video, and XML files, and often have plug-insto support media player programs, e.g., Flash applications and Javaapplets.

There may be situations when multiple instances of a media playerprogram are running in a browser program. Moreover, the browser programhosting the multiple running instances may be executed by a mobiledevice having limited computing resources.

SUMMARY

This specification describes technologies relating to managing computerresources available to multiple running instances of a media playerprogram. Specifically, techniques and systems are disclosed forselectively shutting down instances of the media player program whencomputing resources required for running the multiple instances become,or are in danger of becoming unavailable.

In general, one innovative aspect of the subject matter described inthis specification can be embodied in methods that include the actionsof monitoring consumption of computing resources of multiple runninginstances of a media player program to render respective media contentin a graphical user interface of a computing device. The graphical userinterface associated with an additional program configured to renderadditional content, different from the media content, to the graphicaluser interface. The additional program can be a browser. The methodsfurther include instructing the multiple instances to reduce respectiveportions of the computing resources consumption upon determining that arequested increase in computer resources consumption of the media playerprogram would cause the computer resources consumption of the mediaplayer program to exceed a first predetermined level.

These and other implementations can include one or more of the followingfeatures. Prior to the instructing the methods include, identifyinginstances from among the multiple running instances for immediatereduction of the respective portions of the computing resources, andflagging instances from among the multiple running instances forsubsequent reduction of the respective portions of the computingresources.

The methods can further include determining that a new computerresources consumption of the media player program is above the firstpredetermined level after accounting for the instructed reductions andfor the requested increase. Further, the methods can include selectingone or more instances to be shut down among the multiple instances, andshutting down at least one of the selected instances to bring the newcomputing resources consumption below the first predetermined level.Determining the new computer resources consumption of the media playerprogram can also include determining that the new computer resourcesconsumption is above the first predetermined level and below a secondpredetermined level after accounting for the instructed reductions andfor the requested increase. Shutting down instances can includesequentially shutting down one instance at a time from the multipleinstances until the computing resources consumption is below the firstpredetermined level.

Selecting the instances can be performed according to one or more rulesdesigned to maximize a number of presentations of the respective mediacontent rendered in the graphical user interface. Selecting theinstances further includes (i) determining paused instances of the mediaplayer program that are loaded in background, and selecting thedetermined instances. The background includes portions of the graphicaluser interface not visible on a display screen. Then, selecting theinstances further includes (ii) determining un-paused instances of themedia player program running in the background, and selecting thedetermined instances. Then, selecting the instances includes (iii)determining priority instances of the media player program running inthe background, and selecting the determined instances. A priorityinstance of the media player has a priority assigned by the additionalprogram. Then, selecting the instances includes (iv) determining a focusinstance of the media player program running in the background, andselecting the determined instance. The focus instance represents aninstance of the media player program which has received most recently aninstruction via the graphical user interface. Then, selecting theinstances includes (v) determining helper instances of the media playerprogram running in the background, and selecting the determinedinstances. The helper instances are configured to assist the running ofother instances from the multiple instances. Then, selecting theinstances includes (vi) determining paused instances of the media playerprogram that are loaded in foreground, and selecting the determinedinstances. The foreground includes portions of the graphical userinterface being visible. Then, selecting the instances includes (vii)determining un-paused instances of the media player program running inthe foreground, and selecting the determined instances. Then, selectingthe instances includes (viii) determining priority instances of themedia player program running in the foreground, and selecting thedetermined instances. Then, selecting the instances includes (ix)determining a focus instance of the media player program running in theforeground, and selecting the determined instance. Then, (x) determininghelper instances of the media player program running in the foreground,and selecting the determined instances. The methods can includeperforming the sequentially shutting down one instance at a time inorder of instance selection.

Shutting down the instances can also include presenting graphicalindications of a portion of the shutdown instances, for example, a proxyicon can be displayed in place of a shutdown instance of the mediaplayer program. In some implementations, a click-to-play icon of ashut-down instance can be displayed.

According to another aspect, the described subject matter can also beimplemented in a data processing system including a data storage deviceto store one or more rules for managing consumption of computingresources by multiple running instances of a media player programconfigured to render respective media content in a graphical userinterface of the data processing system. The graphical user interfaceassociated with an additional program is configured to render additionalcontent, different from the media content, to the graphical userinterface. The additional program can be a browser. The system alsoincludes one or more hardware processors communicatively coupled withthe data storage device and configured to perform operations includingmonitoring the consumption of computing resources of the multiplerunning instances of the media player program, and instructing themultiple instances to reduce respective portions of the computingresources consumption upon determining that a requested increase incomputing resources consumption of the media player would cause thecomputing resources consumption of the media player to exceed a firstpredetermined level. The computing resources can include one or more of(i) memory available to the multiple running instances of the mediaplayer program, and (ii) power of the one or more hardware processorsconsumed by the multiple running instances of the media player program.

These and other implementations can include one or more of the followingfeatures. The one or more hardware processors are further configured toperform, prior to carrying out the instructing, operations includingidentifying instances from among the multiple running instances forimmediate reduction of the respective portions of the computingresources, and flagging instances from among the multiple runninginstances for subsequent reduction of the respective portions of thecomputing resources.

The one or more hardware processors are further configured to performoperations including determining that a new computer resourcesconsumption of the media player program is above the first predeterminedlevel after accounting for the instructed reductions and for therequested increase. Selecting one or more instances to be shut downamong the multiple instances, and shutting down at least one of theselected instances to bring the new computing resources consumptionbelow the first predetermined level.

To carry out the determining, the one or more hardware processors arefurther configured to perform operations including determining that thenew computer resources consumption is above the first predeterminedlevel and below a second predetermined level after accounting for theinstructed reductions and for the requested increase. To carry out theshutting down, the one or more hardware processors are furtherconfigured to perform operations including sequentially shutting downone instance at a time from the multiple instances until the computingresources consumption is below the first predetermined level.

The selecting can be carried out by the one or more hardware processorsin accordance with the stored one or more rules for managing themultiple running instances of the media player program. The one or morerules are designed to maximize a number of presentations of therespective media content rendered in the graphical user interface.

To carry out the selecting, the one or more hardware processors arefurther configured to perform operations including (i) determiningpaused instances of the media player program that are loaded inbackground, and selecting the determined instances. Then, (ii)determining un-paused instances of the media player program running inthe background, and selecting the determined instances. Then, (iii)determining priority instances of the media player program running inthe background, and selecting the determined instances. Then, (iv)determining a focus instance of the media player program running in thebackground, and selecting the determined instance. Then, (v) determininghelper instances of the media player program running in the background,and selecting the determined instances. Then, (vi) determining pausedinstances of the media player program that are loaded in foreground, andselecting the determined instances. Then, (vii) determining un-pausedinstances of the media player program running in the foreground, andselecting the determined instances. Then, (viii) determining priorityinstances of the media player program running in the foreground, andselecting the determined instances. Then, (ix) determining a focusinstance of the media player program running in the foreground, andselecting the determined instance. Then, (x) determining helperinstances of the media player program running in the foreground, andselecting the determined instances. The one or more hardware processorsare further configured to perform operations including carrying out thesequentially shutting down one instance at a time in order of instanceselection.

To carry out the shutting down, the one or more hardware processors arefurther configured to perform operations including displayingcorresponding proxy icons in place of at least a portion of the shutdowninstances.

According to another aspect, the described subject matter can also beimplemented in a computer storage medium encoded with a computerprogram, the program including instructions that when executed by dataprocessing apparatus cause the data processing apparatus to performoperations including monitoring consumption of computing resources ofmultiple running instances of a media player program to renderrespective media content in a graphical user interface of a mobiledevice. The graphical user interface associated with an additionalprogram configured to render additional content, different from themedia content, to the graphical user interface. The operations alsoinclude instructing a first group of instances from among the multiplerunning instances to reduce respective portions of the computingresources consumption in response to determining that a requestedincrease in computing resources consumption of the media player programwould cause the computer resources consumption of the media playerprogram to exceed a first predetermined level, and flagging otherinstances from among the multiple running instances to subsequentlyreduce corresponding computer resources consumption. The operations alsoinclude allocating the requested increase in computer resourcesconsumption in response to determining that the computer resourcesconsumption would be less than the first predetermined level afteraccounting for the instructed reduction of the first group of instances.Further, the operations include selecting one or more instances to beshut down among the multiple instances in response to determining that anew computer resources consumption, after accounting for the instructedreductions of the first group of instances and of the flagged instancesand for the allocation, is greater that a second predetermined level.The operations further include shutting down at least a portion of theselected instances to bring the computing resources consumption belowthe second predetermined level.

Particular embodiments of the subject matter described in thisspecification can be implemented so as to realize one or more of thefollowing advantages. Closing media player instances that are running ina browser program may be carried out according to computing resourcesavailable to a particular mobile device executing the browser program.The foregoing, allows a user to interact with the browser programwithout having to be mindful of the resource requirements necessary todo so. This can provide the user with a substantially similar userexperience regardless of the type of mobile device used to execute thebrowser program hosting the multiple running instances of the mediaplayer. Similar advantages may also be realized within the context ofanother execution environment, different than a browser program.

Additionally, the techniques described in this specification can makemore efficient use of limited computing resources available on a mobiledevice, enabling allocation of computing resources to other tasksperformed by the mobile device. Further, the disclosed techniques can beused to close down single instances without closing all runninginstances of the media player program. Furthermore, a browser program(or other execution environment) running on a mobile device may becomemore responsive and more stable and may avoid crashing, because theinstance shutdowns can be performed cleanly. In addition, having themedia player program, rather than the browser or other executionenvironment, decide when to shut down one or more multiple runninginstances may be potentially advantageous because the media playerprogram can determine a relative priority of content played by themultiple instances running instances, and can take measures to avoidshutting down particular instances as necessary.

The details of one or more implementations of the subject matterdescribed in this specification are set forth in the accompanyingdrawings and the description below. Other features, aspects, andadvantages of the subject matter will become apparent from thedescription, the drawings, and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows diagrams of an example of a system for running multipleinstances of a media player program.

FIG. 2 shows a schematic diagram of an example of a system for managingmultiple instances of a media player program.

FIG. 3 shows an example of a method for managing computing resourcesconsumed by multiple running instances of a media player program.

FIGS. 4A and 4B show aspects of the method for managing computingresources consumed by the multiple running instances of a media playerprogram.

FIGS. 5A and 5B show other examples of methods for managing computingresources consumed by multiple running instances of a media playerprogram.

FIGS. 6A and 6B show an example of a method for selecting instances tobe shut down from among the running instances of a media player program.

FIG. 7 shows other aspects of the method for managing computingresources consumed by the multiple running instances of a media playerprogram.

FIGS. 8A-8C show examples of various aspects of implementations of asystem and method for managing the computing resources consumed by themultiple running instances of a media player program.

Like reference numbers and designations in the various drawings indicatelike elements.

DETAILED DESCRIPTION

As shown in FIG. 1, an example of a system 100 for running multipleinstances of a media player program includes a mobile device 110. Mobiledevice 110 can include a touchscreen device 120, which can be configuredas a graphical user interface (GUI) for multiple programs running onmobile device 110. System 100 further includes a program 130 and a mediaplayer program 150. The media player program 150 can be included in orotherwise can be accessible to program 130.

Program 130 can represent a web browser program or another program thatprovides an execution environment (e.g., a cross-platform runtimeenvironment). Program 130 is configured to render webpage content andcan include multiple instances W1-W4. In some implementations, themultiple instances W1-W4 of the browser program can represent browserwindows, browser tabs, cards, and the like. Instances W1-W4 of thebrowser program can render respective webpages. In addition, eachinstance of the browser program, e.g. W2, can display a portion 132 of awebpage, while a non-displayed portion 136 of the webpage remains hiddenfrom view. A scrollbar 134 or other GUI mechanism can allow usersassociated with device 110 to interactively select which portion of thewebpage to display in the browser instance, by moving scrollbar 134 upor down (e.g. in W2), and left or right (e.g. in W3). Additionally, auser can select a browser instance from among the multiple browserinstances W1-W4 by tapping on an associated browser tab. Further, a usercan remove a browser instance from the foreground of the browser program(and can push the removed browser instance into the background ofbrowser program) by swiping on the foreground browser instance.

Media player program 150 can render media content associated with awebpage. The media content includes one or more types such as, forexample, video, audio, media animation, still images, text, interactivecontent forms, and the like. Further, multiple instances of media player150 can run within corresponding browser instances W1-W4. In the examplesystem 100 illustrated in FIG. 1, browser instance W1 includes mediaplayer instances MPI1 and MPI2; browser instance W2 includes mediaplayer instances MPI3, MPI4 and MPI5; browser instance W3 includes mediaplayer instances MPI6, MPI7 and MPI8; and browser instance W4 includesmedia player instances MPI9 and MPI10.

A running instance of media player program 150 consumes computingresources available to mobile device 110. Additionally, ones among therunning media player instances that may be playing media content consumemore computing resources than other ones among the running media playerinstances that can be paused. In the example system 100 illustrated inFIG. 1, media player instances MPI1, MPI3, MPI5, MPI6, MPI7, MPI9 andMPI10 are playing content, while media player instances MPI2, MPI4 andMPI8 are paused, at the current time.

The computing resources consumed by device 110 for running multipleinstances MPI1-MPI10 can include memory, power and cycles of one or moreprocessors power or processor cycles, network bandwidth, battery life,multiple CPUs and graphics coprocessors and the like. Memory, processorpower and battery life tend to be limited resources on mobile devices110. In many cases, there is no practical way to determine how muchmemory or processor power a given instance of a media player program mayrequire prior to running the given instance. This means that there maybe no way to know if the given media player instance can run on mobiledevice 110 before actually starting and running the given instance.

FIG. 2 shows a schematic diagram of an example of a data processingsystem 200 for managing multiple instances MPI(1), . . . , MPI(N) of amedia player program 250. Data processing system 200 can representanother implementation of system 100. For example, media player program250 and its instances MPI(1), . . . , MPI(N) can correspond to mediaplayer program 150 and its instances MPI1, . . . , MPI10. Furthermore,an additional program 230 and its user interface 234 can respectivelycorrespond to program 130 and its user interface 132-136. Also,interface 220 of data processing system 200 can correspond totouchscreen device 120 of mobile device 110. Media player program 250can use an instance manager 270 to determine if there is sufficientmemory or processor power for running instances MPI(1), . . . , MPI(N)of the media player program 250. Instance manager 270 is configured toperform the foregoing determination by parsing information gathered fromrunning instances MPI(1), . . . , MPI(N), from a memory manager 260 ofmedia player 250, and from an operating system 212 associated withsystem 200, as described in detail below. Note that, although shown aspart of media player program 250, one or both of memory manager 260 andinstance manager 270 can be separate programs from media player program205.

If the determination indicates that there are insufficient computingresources for running instances MPI(1), . . . , MPI(N), the instancemanager 270 can take action to release computing resources from thegiven instance and other instances, which are running at the time of thedetermination, so that, for example, the given instance can keeprunning. Alternatively, when no additional computing resources can beaccessed, instance manager 270 can shut down the given instance and theother running instances of the media player. By performing theseactions, instance manager 270 can potentially enable media playerprogram 250 to access computing resources of data processing system 200in a controlled manner and, for example, to gradually shut downinstances of media player program 250 when the computing resourcesconsumption is too high.

In operation, a media player program 250 can manage its instances,MPI(1), . . . , MPI(N), to keep memory consumption as low as possiblewhile also not over taxing a processor of system 200. Memory manager 260of the media player program is configured to control memory consumptionin a proactive and continual manner, not only in reaction to low memorysituations. Because memory manager 260 tunes the media player's memoryconsumption to allow running instances MPI(1), . . . , MPI(N) to performoptimally, using as little memory as necessary, then when media playerprogram 250 runs out of memory, instance manager 260 can turn toshutting down a subset of player instances MPI(1), . . . , MPI(N) torelease some of the memory back to media player program 250. Workingtogether, memory manager 260 and instance manager 270 avoid situationswhen media player program 250 functions at ever lower performance levelsuntil a player performance becomes unacceptably slow. When there is morethan one active player instance and there are indications of highcomputing resources consumption, instance manager 270 can select aplayer instance to shut down while leaving the others running. Theselection can be performed based on rules 275 for selecting which playerinstances to shut down. For example, the instance that is selected byinstance manager 270 for shutdown may not necessarily be the one thatruns out of memory. Multiple rules 270 are described in detail below.Further, rules 275 can be stored in a data storage device 214 of dataprocessing system 200.

Memory manager 260 can allocate memory for all player instances MPI(1),. . . , MPI(N) from a shared pool of memory. The memory used by oneactive player instance is not available for another active playerinstance, and memory released by one active player instance can beavailable for another active player instance. If system 200 reaches astate where the memory manager 260 cannot allocate more memory, allplayer instances MPI(1), . . . , MPI(N) may fail unless action is takento provide memory resources. In some cases, none of the player instancesMPI(1), . . . , MPI(N) can continue to receive memory until theavailable memory pool is restored. For example, the memory manager 260can provide a callback to instance manager 270 to request more memory.If this callback can return enough memory to the memory manager 260 tosatisfy the current request, then the player instances MPI(1), . . . ,MPI(N) can continue to operate normally, for a while. But it is quitelikely that another out of memory (OOM) situation may soon follow.

Instance manager 270 is configured to shut down one player instance,rather than all of them, as a first response. Additionally, instancemanager 270 is configured to perform the shutting down as cleanly(normally) as possible. However in some situations, instance manager 270can shut down all player instances MPI(1), . . . , MPI(N) at once toavoid crashing the additional program 230, which hosts the runningplayer instances MPI(1), . . . , MPI(N). In the case when all playerinstances MPI(1), . . . , MPI(N) are simultaneously closed, instancemanager 270 bypasses normal shutdown of the player instances. However,such aborting of player instances MPI(1), . . . , MPI(N) may not be aclean shutdown process, because such aborting bypasses running classdestructors, and the like. Instance manager 270 is configured tosequentially shut down single instances cleanly, only when necessary,and is designed to avoid the abort scenario. Since instance manager 270cannot determine a priori whether media player program 250 can recoverenough memory to shut down cleanly, instance manager 270 can use thedescribed emergency shutdown procedure as a backup.

FIG. 3 shows an example of a method 300 for managing computing resourcesconsumed by multiple running instances of a media player program. Method300 can be implemented, for example, by data processing system 200.Method 300 includes monitoring 310, by instance manager 270, consumptionof computing resources of multiple running instances of a media playerprogram 250. The instances of media player program 250 render respectivemedia content in a graphical user interface 234 of system 200. Graphicaluser interface 234 can be associated with an additional program 230configured to render additional content to graphical user interface 234.The additional content rendered by additional program 230 is differentfrom the media content rendered by media player program 250. Additionalprogram 230 can be a browser program, and the additional content canrepresent webpage content.

Method 300 continues with instance manager 270 instructing 320 themultiple instances to reduce respective portions of the computingresources consumption upon determining that a requested increase incomputer resources consumption of the media player program 250 wouldcause the computer resources consumption of the media player program 250to exceed a first predetermined level. Media player program 250 can bein a normal state of consumption when consuming computing resourcesbelow the first predetermined level, and can be in a marginal state ofconsumption when consuming computer resources above the firstpredetermined level. The instructed reduction is intended tocumulatively release enough computing resources from all of the runninginstances to cause a transition from the marginal state to the normalstate of consumption. In some implementations, when the computingresources represent memory, the first predetermined level corresponds toa soft limit of memory consumption as described in detail below.

In particular situations, memory manager 260 can request that a givenamount of memory be allocated by operating system 212 to media playerprogram 250, and such request cannot be honored by operating system 212.In these particular situations, instead of aborting the running playerinstances of media player 250, instance manager 270 can instruct therunning player instances to reduce respective portions of memoryconsumption. The memory released in this manner can be allocated bymemory manager 260 to honor the foregoing request of media playerprogram 250. As detailed below in connection with FIGS. 5A and 5B, therunning player instances can perform the instructed reductionsynchronously (i.e. when receiving the instruction,) or asynchronously(i.e. at a later time,) depending on respective execution states of therunning instances.

FIG. 4A shows another example of a method 400 for managing computingresources consumed by the multiple running instances of a media playerprogram. Data processing system 200 can combine method 400 with method300. For example, method 400 can be executed prior to instructing 320the multiple instances to reduce respective portions of the computingresources consumption. Method 400 includes identifying 412 instancesfrom among the multiple running instances for immediate reduction of therespective portions of the computing resources. For example, some of therunning instances may be at stages of execution when they can reducerespective computing resources consumption (e.g., clear caches, collectgarbage, and the like) upon receiving such instruction. Inactiveinstances, such as e.g. paused instances, can be identified in thismanner to release memory back to operating system 215, immediately afterbeing so instructed.

Method 400 further includes flagging 414 instances from among themultiple running instances for subsequent reduction of the respectiveportions of the computing resources. For example, some of the runninginstances may be at stages of execution when they cannot reducerespective computing resources consumption (e.g., clear caches, collectgarbage, and the like) upon receiving such instruction. Activeinstances, such as e.g. instances currently playing media content, canbe flagged in this manner to release memory back to operating system215, at a later time after being so instructed, for example, aftercompleting currently running tasks. The identifying 412 and flagging 414aspects of method 400 are described in detail with respect to FIGS. 5Aand 5B.

FIG. 4B shows another example of a method 450 for managing computingresources consumed by the multiple running instances of a media playerprogram. Data processing system 200 can combine method 450 with methods300 and 400. For example, method 450 can be executed after instructing320 the multiple instances to reduce respective portions of thecomputing resources consumption. Method 450 includes determining 460that a new computer resources consumption of the media player program250 is above the first predetermined level after accounting for theinstructed reductions and for the requested increase. For example,instance manager 270 and memory manager 260 can assess an effect of theinstructed reductions carried out synchronously, by a number ofidentified instances, and asynchronously, by another number of flaggedinstances. A result of determining 270 can be that the current computerresources consumption is still above the first predetermined level. Incase the first predetermined level represents a soft level of memoryconsumption, method 450 can continue with instance manager 270 selecting470 one or more instances to be shut down among the multiple instances.The selecting 470 aspect of method 450 is discussed in detail below inconnection with FIGS. 6A and 6B. However prior to selecting 470,instance manager 270 can also determine 465 that the new (current)computer resources consumption of the media player program 250 is abovethe first predetermined level and is also below a second predeterminedlevel after accounting for the instructed reductions and for therequested increase. The second predetermined level can correspond to ahard level of memory consumption, when operating system 215 cannotallocate memory requested by media player system 250. Thus, bydetermining 465 that the new computer resources consumption of the mediaplayer program 250 is below the hard level, instance manager 270 cansafely performing the subsequent aspects of method 450.

Method 450 further includes shutting down 480 the selected instances tobring the computing resources consumption below the first predeterminedlevel. For example, instance manager 270 can sequentially shut down 485one instance at a time from the selected instances until the computingresources consumption is decreased from above the first predeterminedlevel to below the first predetermined level. For example, instancemanager 270 can shut down a first selected instance of the media playerprogram, and then can detect whether the media player program 250 hastransitioned from the marginal state, where consumption of computingresources is above the first predetermined level, to the normal statewhere the consumption of computing resources is below the predeterminedlevel. If no such transition can be detected, then instance manager 270shuts down 485 a second selected instance of the media player program.Instance manager continues to toggle between determining whether thetransition from marginal state to normal state has occurred and shuttingdown 485 one instance at time from among the instances selected forclosing, until the transition from the marginal state to the normalstate of computing resources consumption is detected.

As described above, systems 100 and 200, and methods 300, 400 and 450can be used to handle out of memory (OOM) conditions. The systems andmethods disclosed in this specification can also be used to triggerinstance shutdown based on logic to maintain a minimum frame rate forone or more media player instances. The logic for instance shutdownselection may be similar to the selection rules discussed below.Additionally, the methods disclosed in this specification can be used topause an instance instead of shutting it down when computing resourcesbecome less readily available. In some implementations, selectedinstances can be suspended to reduce their respective memory consumptionwithout shutting them down. In general, the disclosed methods andsystems can be used to iterate through and select instances based onpriority to improve performance of the media player program as needed.

The first predetermined level of computing resources consumptiondescribed above in reference to aspect 320 of method 300 can beimplemented as a soft limit. The soft limit can differ from device todevice and so a variable corresponding to the soft limit can have acompile time default that can be modified for each device build. In someimplementations, the soft limit can be a constant for each device type.For builds corresponding to desktop devices, the soft limit can defaultto unlimited (like heapHardLimit,) but can be overridden inconfiguration files (e.g., in oem.cfg) for testing purposes. Forexample, a configuration file can include a tag called heapSoftLimit toallow setting the soft limit size in megabytes like the heapHardLimit.

In some implementations, memory manager 260 can trigger akFreeMemoryIfPossible OOM callback when the memory consumption growslarger than the current soft limit. When the memory consumptionincreases over the soft limit, memory manager 260 is configured to nottrigger logic for memory abort. An actual failure to allocate, due to asystem allocation failure, or heapLimit, causes memory manager 260 totrigger kFreeMemoryIfPossible followed by kMemAbort. The soft limittrigger can additionally be used, by instance manager 270, as a signalto trigger the instance management logic. If the media player program250 is in a marginal state of memory consumption, e.g. calledkMemSoftLimit, when memory is freed, and if the freeing of memory causesthe memory consumption to drop below the soft limit, the media playerprogram 250 may return to a normal state of memory consumption, e.g.called kMemNormal.

Additionally, memory manager 260 is further configured to register forOOM callbacks and to force garbage collection on each player instance'smemory consumption in response to a kFreeMemoryIfPossible OOM callbackand a transition to the marginal state kMemSoftLimit. Since a largenumber of memory allocations may occur while in the marginal statekMemSoftLimit, memory manager 260 is configured to collect on statetransitions and not on every allocation/access in that state to avoidthrashing.

The OOM callback for kFreeMemoryIfPossible may or may not release anymemory within the synchronous callback. The purpose of this OOM callbackis to trigger logic that can asynchronously release memory. Whilepossible, it is not required for the player instances to release memorysynchronously upon a kFreeMemoryIfPossible callback. For example, playerinstances that are not currently running can be called synchronously tofree memory. The soft limit can trigger before the system runs out ofmemory, so in most cases there may be extra memory to complete thecurrent operations on the stack. Shortly afterwards, the asynchronousscheduled actions may cause extra memory to be released and memory usagecan again fall below the soft limit.

Note that the kFreeMemoryIfPossible callback can also be triggered whenthe media player program 250 hits another predetermined level higherthan the soft limit. The second predetermined level of computingresources consumption described above in reference to aspect 465 ofmethod 450 may be implemented as a hard limit. In that case, when thememory consumption were to increase above the hard limit, and if enoughmemory to satisfy the kFreeMemoryIfPossible request cannot be acquired,the kMemAbort logic can be triggered to shut down all player instances.

Instance manager 270 is configured to provide an OOM callback to releaseplatform resources when an out of memory situation occurs. Instancemanager 260 can implement instance shutdown logic that includesregistering an OOMCallback to the GCHeap logic implemented by memorymanager 260. To implement such logic, instance manager 270 can add anOOMCallback through logic executed by memory manager (GCHeap()→AddOOMCallback(OOMCallback*)). The registration of the instancemanager's callback is performed early, while global variables of coreplayer 250 are first initialized. For example, an OOMCallback can handlea transition from kMemNormal to kMemSoftLimit. This callback may beresponsible for releasing resources of running player instances.

When there are multiple running player instances, instance manager 270can select an instance to shut down. The selection process can includecalculating a priority value for each instance. The player instancehaving the lowest priority value can be selected for shut down. Apriority value for a given instance of the media player program can becalculated based on multiple characteristics of the given instance.

For example, a priority value can be assigned to the given instance inresponse to determining whether the given instance is running in theforeground or in the background. In example system 100, media playerinstances MPI1 and MPI2 are loaded in foreground instance W1 of program130. Further, player instances in a frame on a foreground tab of abrowser can be given higher priority than any instance in a backgroundtab. If the foreground browser tab has player instances in multipleframes, only one of the frames can be considered to be in theforeground, and the others instances running in other frames of theforeground tab can be treated as if they were in a background tab.

Further, a priority value can be assigned to the given instance inresponse to determining whether the given instance is a helper instanceof the media player program. A helper instance can be a hidden and/or atiny (e.g., 1-2 pixels) media player instance that can be configured tocontrol other media player instances running in a browser and HTMLelements of a webpage presented by the browser. In example system 100,media player instances MPI5 and MPI10 are helper instances running inrespective instances W2 and W4 of program 130. The helper instances arethe last ones to shutdown. When instance manager 270 can select a helperinstance for shutdown, instance manager 270 also switches all the otherplayer instances on this webpage to OOM state because the otherinstances may not be reliably restarted when the helper media playerinstance is not running.

Furthermore, a priority value can be established for the given instancein response to determining a previously assigned priority to the giveninstance. For example, html flags corresponding to the given instancecan specify whether media content rendered by the given instance on awebpage has priority over other media content rendered by otherinstances running on the webpage. The previously assigned priority canbe set with a “hasPriority” flag. Such flag can be set for each activeinstance as it is started so that the flags can be used to determinewhich instances can be kept in memory if possible. In example system100, media player instances MPI7, MPI8 and MPI6 running in instance W3of program 130 have pre-assigned priority 1, 2 and 3 respectively.

Additionally, a priority value can be assigned for the given instance inresponse to determining that the given instance is in focus. Instancemanager 270 can place top priority on keeping content that a user hasmost recently interacted with. Throughout this specification, theforegoing property is called “focus”. It is possible that no runninginstance is in focus, for example, when a webpage loads and the user hasnot interacted with any of the running instances, yet. In example system100, media player instance MPI9 running in background instance W4 ofprogram 130 has focus, as being the last instance that a user associatedwith mobile device 110 has interacted with. Further, focus can berecorded as a mouse/pen/finger touch within the content area of themedia player instance. Such touch can mark that instance as having theuser focus.

Also, a priority value can be assigned for the given instance inresponse to determining whether the given instance is paused. Instancescan be paused due to going off-screen (either in background browsertabs, or in on off-screen area 136 of a webpage.) Off-screen instancesmay not be paused if they have high pre-assigned priority or if theycontain active audio/video content. In example system 100, media playerinstances MPI2, MPI4 and MPI8 loaded in respective instances W1, W2 andW3 of program 130 are paused.

In addition, a priority value can be assigned for the given instance inresponse to determining whether the given instance is at least partiallyvisible to a user of the mobile device at the current time. In examplesystem 100, media player instances MPI1 and MPI2 loaded in foregroundinstance W1 of program 130 are visible.

In accordance with the instance characteristics described above,instances of a media player program running in a web browser program canbe prioritized as follows:

(1) Keep the helper instance if it exists in the foreground.

(2) Keep the focus instance if it exists in the foreground.

(3) Keep all priority instances in the foreground.

(4) Keep any un-paused user visible instances in the foreground.

(5) Keep any paused instances in the foreground.

(6) Keep the helper instance if it exists in the background.

(7) Keep the focus instance if it exists in the background

(8) Keep all priority instances in the background

(9) Keep any un-paused instances in the background

(10) Keep any paused instances in the background

If there are multiple background tabs W2-W4, they may not be prioritizedas groups. For example all paused instances in all background tabs W2-W4can be shut down before shutting down a priority instance in thebackground tabs. If the remaining choices are equal, instance manager270 is configured to simply release the next instance in sequence (asloaded from the website). If the instance to be shutdown is a helperinstance (FC5 or FC10), then all the player instances on the webpage (W2or W4, respectively), are being switched to OOM state.

Releasing a player instance can happen asynchronously to the OOMcallback. For example, the callback may callplayer→SetPlayerUnloadStatus( ). Specialized code within the platformtimer logic can detect this state before calling the doPlay loop of thatplayer instance. At that point, the player instance can be unloaded,while the instance manager 270 may present a click-to-play icon to allowrestarting of the shutdown instance.

Shutting down a player instance may release enough memory to drop memoryusage lower than the soft limit. In addition to shutting down a singleinstance, all player instances can free extra resources if possible onhitting the memory soft limit. To ensure this can be done safely, eachplayer instance can be flagged by instance manager 270 to cleanupresources on the next doPlay entry, for example. In this example, codeof instance manager 270 (e.g., GCHeap code) may automatically check oneach player instance for a transition back to kMemNormal status. Oncethis happens, crossing the soft limit again may repeat the same sequenceof events. In some implementations, only one OOMCallback may begenerated for each transition.

FIGS. 5A and 5B show examples of methods 500 and 550 for managingcomputing resources consumed by multiple running instances of a mediaplayer program. Methods 500 and 550 can be implemented, for example, insystems 100 or 200.

Referring to FIG. 5A, method 500 includes determining 505, by aninstance manager, that the operating system cannot satisfy a previousrequest for allocating computing resources. For example, in case one ofmultiple running instances of the media player program requests a chunkof memory that would cause a memory consumption of the media playerprogram to exceed a predetermined hard level, then the operating systemwould deny such a request.

Method 500 continues with the instance manager iterating 510 through themultiple running instances of the media player program for instructingthe multiple running player instances to cleanup respective computingresources. By doing so, the multiple running player instances maycollectively return back to the operating system at least a portion ofthe currently used computing resources. In this manner, the operatingsystem may regain the at least a portion of computing resources releasedby the running player instances to honor the previously deniedallocation request from the media player program.

Method 510 includes checking 512, by the instance manager, whether agiven player instance is currently available for performing a cleanupprocess. For example, the given player instance can be unavailable tocleanup respective computing resources because it may need to completepreviously scheduled tasks. In another example, a player instance can beunavailable to cleanup respective computing resources because it isactively playing media content. Method 500 includes flagging 516 of theunavailable player instances for cleaning at a later time. As part offlagging 516, the instance manager can queue currently unavailableplayer instances for asynchronous processing, i.e., for cleaning at asubsequent time. Upon queuing 516 the given player instance forsubsequent cleanup, the instance manager can return to polling 510 anext player instance of the media player program. Moreover, method 500can exit the polling loop upon polling 510 all running instances of themedia player program.

However, as a result of checking 512, the instance manager can determinethat the given player instance is available to cleanup respectivecomputing resources upon receiving an instruction to do so. For example,the given player instance may be available to immediately cleanuprespective computing resources because it may have completed previouslyscheduled tasks. In another example, a player instance may be availableto cleanup respective computing resources because it is currentlyinactive (e.g., paused, placed in a low memory state, stopped, and thelike.) The available player instances can be instructed 514 to cleanuprespective computing resources synchronously, i.e., upon receipt of theinstructions. Examples of resource cleaning 514 performed by the givenplayer instance are cleaning memory caches and collecting garbage.

The instance manager can continue performing method 500 by determining518 whether the computing resources released back to the operatingsystem due to the cleaning 514 performed by the given player instancewould cause the operating system to honor the previously deniedallocation request. When a result of determination 518 is negative, thenthe instance manager can return to polling 510 a next instance of themedia player program. Further, upon polling 510 all running instances ofthe media player program, method 500 can exit the polling loop.Furthermore, when the result of determination 518 is positive, theinstance manager can exit the polling loop without having to iteratethrough all running player instances. Upon exiting the polling loop inthis later manner, method 500 can continue with the media player programreceiving 530 from the operating system the requested computingresources allocation.

When method 500 exits the polling loop after polling 510 all runninginstances of the media player program, the instance manager can verify520 whether a consumption of computing resources would exceed thepredetermined hard level after accounting for the iterative synchronouscleanups 514 and for the requested allocation. When a result of theverification 520 is positive, the operating system would continue todeny the requested allocation. In this situation, method 500 includesaborting 540 by the media player program, of all running playerinstances to free computing resources used by the media player program.When a result of the verification is negative, method 500 can continuewith the media player program receiving 530 from the operating systemthe requested computing resources allocation.

Referring to FIG. 5B, method 550 can be implemented by an instancemanager after completing method 500. Further, method 550 can beimplemented to release additional computing resources back to theoperating system, for example, via cleanups to be executedasynchronously by player instances which have been flagged 516 forcleaning as part of method 500. Moreover, method 550 can be implementedby iterating 555 through each running instance of the media playerprogram.

Once the instance manager picks 555 a given player instance forasynchronous processing, method 550 includes checking 560 whether thegiven player instance has been selected to be shut down. At least at thebeginning of a first iteration 555, no player instances have beenselected to be shut down yet. The conditional steps of method 550 thatare traversed prior to the instance manager performing a first suchselection are described in detail below.

In situations when the instance manager determines 560 that the givenplayer instance has not been selected to be shut down, method 550continues with the instance manager verifying 562 whether the givenplayer instance has been flagged 516 for cleanup. Method 550 cancontinue 590 with the media player program performing other type ofprocessing upon verifying 562 that the given player instance has notbeen flagged 516 for cleanup. However upon verifying 562 that the givenplayer instance has been flagged for cleanup, method 550 includesinstructing 564 the given player instance to cleanup computingresources. Examples of resource cleaning 564 performed by the givenplayer instance are cleaning memory caches and collecting garbage.

Method 550 continues with the instance manager determining 568 a currentcomputing resources consumption. Method 550 can continue 590 with themedia player program performing other type of processing when thedetermined computing resources consumption is below a predetermined softlevel, i.e., the media player program is in a normal state of computingresources consumption. However, when the determined computing resourcesconsumption is above the predetermined soft level, i.e., the mediaplayer program is in a marginal state of computing resourcesconsumption, method 550 continues with the instance manager checking 570whether any other player instances has been flagged 516 for cleanup.Method 550 can continue 590 with the media player program performingother type of processing when the instance manager determines 570 thatone or more other player instances are in queue for cleanup.

Moreover when the instance manager determines 570 that no other playerinstances are in queue for cleanup, method 550 continues with theinstance manager selecting 580 a particular player instance from amongthe multiple running instances of the media player program to be shutdown. The selecting 580 can be performed based on the priority list(1)-(10) described above, and in accordance with selection rulesdescribed below in connection with FIGS. 6A and 6B. After selecting 580the particular player instance for shutdown, method 550 can continue 590with the media player program performing other type of processing.

In other situations, the instance manager can determine 560 that thegiven player instance has been selected to be shut down. Then, method550 can continue with the instance manager shutting down 566 the givenplayer instance that has been queued 580 for shutting down. Method 550further includes determining 568 a computing resources consumption afteraccounting for shutting down 566 the given player instance. Method 550can continue 590 with the media player program performing other type ofprocessing when determining 568 that the computing resources consumptionis below the predetermined soft level, i.e., the media player program isin the normal state of computing resources consumption. However, whendetermining 568 that computing resources consumption is above thepredetermined soft level, i.e., the media player program is in themarginal state of computing resources consumption, method 550 continueswith the instance manager checking 570 whether any other playerinstances has been flagged for cleanup. As the instance managerdetermines 570 that no other player instances are in queue for cleanup,method 550 continues with the instance manager selecting 580 anotherplayer instance from among the remaining running instances of the mediaplayer program to be shut down. Method 550 can then continue 590 withthe media player program performing other type of processing.

FIGS. 6A and 6B show an example of a method 600 for selecting instancesto be shut down from among the running instances of a media playerprogram. Method 600 can be implemented, for example, in systems 100 or200. Further, method 600 can be combined with method 300 forimplementing the selecting 330 of one or more instances to be shut downamong the multiple instances in response to determining that thecomputing resources consumption has remained above a predeterminedlevel. Additionally, method 600 can be combined with method 550 forimplementing the selecting 580 of a player instance to shut down amongmultiple running instances in response to determining that the mediaplayer program remains in a marginal state of memory consumption.

The selection of one or more instance to be shut down can be performedby an instance manager associated with the media player programaccording to one or more rules designed to maximize a number ofpresentations of the respective media content rendered in the graphicaluser interface. For example, the selection can be carried out inaccordance with the priority list (1)-(10) described above.

Method 600 can include (i) determining paused instances of the mediaplayer program loaded in background, and (i′) selecting the determinedinstances. The background includes portions of the graphical userinterface that are non-visible. In example system 100, media playerinstances MPI4 and MPI8 are paused in respective background instances W2and W3 of program 130, and can be selected based on rule (i)-(i′).

Method 600 can continue with the instance manager (ii) determiningun-paused instances of the media player program running in thebackground, and (ii′) selecting the determined instances. In examplesystem 100, media player instances MPI3, MPI5, MPI6, MPI7, MPI9 andMPI10 are running in background instances W2, W3 and W4 of program 130,and can be selected based on rule (ii)-(ii′).

Method 600 can continue with the instance manager (iii) determiningpriority instances of the media player program running in thebackground, and (iii′) selecting the determined instances. A priorityinstance of the media player has a priority pre-assigned by theadditional program (e.g., by the program 130.) In example system 100,media player instances MPI6, MPI8 and MPI7 have respective priority 3, 2and 1 assigned by an instance of program 130 running in backgroundinstance W3, and can be selected based on rule (iii)-(iii′).

Method 600 can continue with the instance manager (iv) determining afocus instance of the media player program running in the background,and (iv′) selecting the determined instance. The focus instancerepresents an instance of the media player program which has receivedmost recently an instruction via the graphical user interface. Inexample system 100, media player instance MPI9 running in backgroundinstance W4 of program 130 has focus, and can be selected based on rule(iv)-(iv′).

Method 600 can continue with the instance manager (v) determining helperinstances of the media player program running in the background, and(v′) selecting the determined instances. The helper instances areconfigured to assist running of other instances from the multipleinstances. In example system 100, media player instances MPI5 and MPI10are helper instances running in respective background instances W2 andW4 of program 130, and can be selected based on rule (v)-(v′).

Method 600 can continue with the instance manager (vi) determiningpaused instances of the media player program loaded in foreground, and(vi′) selecting the determined instances. The foreground includesportions of the graphical user interface being visible. In examplesystem 100, media player instance MPI2 is paused in foreground instanceW1 of program 130, and can be selected based on rule (vi)-(vi′).

Method 600 can continue with the instance manager (vii) determiningun-paused instances of the media player program running in theforeground, and (vii′) selecting the determined instances. In examplesystem 100, media player instance MPI1 is running in foreground instanceW1 of program 130, and can be selected based on rule (vi)-(vi′).

Method 600 can continue with the instance manager (viii) determiningpriority instances of the media player program running in theforeground, and (viii′) selecting the determined instances. In examplesystem 100, neither of media player instances MPI1 and MPI2 running inforeground instance W1 of program 130 has a pre-assigned priority, so noinstance in example system 100 can be selected based on rule(viii)-(viii′).

Method 600 can continue with the instance manager (ix) determining afocus instance of the media player program running in the foreground,and (ix′) selecting the determined instance. In example system 100,neither of media player instances MPI1 and MPI2 running in foregroundinstance W1 of program 130 is in focus, so no instance in example system100 can be selected based on rule (ix)-(ix′).

Method 600 can continue with the instance manager (x) determining helperinstances of the media player program running in the foreground, and(x′) selecting the determined instances. In example system 100, neitherof media player instances MPI1 and MPI2 running in foreground instanceW1 of program 130 is a helper instance, so no instance in example system100 can be selected based on rule (x)-(x′).

Finally, method 600 continues with the instance manager sequentiallyshutting down 640 one instance at a time in order of instance selection.

In some implementations of method 600, the instance selection can beperformed in accordance with rules (i)-(i′), . . . , and (x)-(x′). Inother implementations of method 600, the instance selection can becarried out in accordance with one or more of rules (i)-(i′), . . . ,and (x)-(x′). In some other implementations of method 600, the instanceselection can be executed in accordance with one of rules (i)-(i′), . .. , or (x)-(x′).

FIG. 7 shows other aspects of the method 450 for managing computingresources consumed by the multiple running instances of a media playerprogram. Shutting down 740 of the selected instances of the media playerprogram can be performed by instance manager 270 and can includepresenting 745 graphical indications of at least some of the shutdowninstances. For example, presenting 745 graphical indications can includedisplaying 748 a proxy icon in place of a shutdown instance of the mediaplayer program. In some implementations, shutting down 740 can includedisplaying a click-to-play icon of a shut-down instance. In otherimplementations, aborting 570 can include displaying an out-of-memoryicon of an aborted instance.

FIGS. 8A-8C show aspects of example implementations of the systems andmethods disclosed in this specification. FIG. 8A illustrates sixinstances 850-1, . . . , 850-6 of a media player program that are loadedin a webpage displayed in browser window 830, at time T1. The underlyingmedia player program has enough memory to run three 850-3, 850-4 and850-5 of the six instances, while the other three instances 850-1, 850-2and 850-6 are shut down. Each of the closed instances displays aclick-to-play icon.

FIG. 8B illustrates the six instances 850-1, . . . , 850-6 of the mediaplayer program loaded on the webpage, at a later time T2. A user tappedon the click-to-play icon of the top right corner instance 850-2 of themedia player program, sometime between T1 and T2. At time T2, fourinstances 850-2, 850-3, 850-4 and 850-5 are running at the same time,while the remaining instances 850-1 and 850-6 are shut down. However,the medial player program does not have enough memory to run the fourinstances 850-2, 850-3, 850-4 and 850-5 at the same time, so one of therunning instances is selected by the instance manager to be closed. Theinstance 850-2 that was clicked by the user has focus and, thus, hashigher priority than the other running instances 850-3, 850-4 and 850-5.Therefore the focus instance 850-2 can not be selected for shutdown.

FIG. 8C illustrates the six instances 850-1, . . . , 850-6 of the mediaplayer program loaded on the webpage, at a later time T3. Three of thesix instances 850-2, 850-3 and 850-5 are running at T3, while the otherthree instances 850-1, 850-4 and 850-6 are closed. Instance 850-4 wasthe last instance shut down by the instance manager.

Embodiments of the subject matter and the operations described in thisspecification can be implemented in digital electronic circuitry, or incomputer software, firmware, or hardware, including the structuresdisclosed in this specification and their structural equivalents, or incombinations of one or more of them. Embodiments of the subject matterdescribed in this specification can be implemented as one or morecomputer programs, i.e., one or more modules of computer programinstructions, encoded on computer storage medium for execution by, or tocontrol the operation of, data processing apparatus. Alternatively or inaddition, the program instructions can be encoded on anartificially-generated propagated signal, e.g., a machine-generatedelectrical, optical, or electromagnetic signal, which is generated toencode information for transmission to suitable receiver apparatus forexecution by a data processing apparatus. A computer storage medium canbe, or be included in, a computer-readable storage device, acomputer-readable storage substrate, a random or serial access memoryarray or device, or a combination of one or more of them. Moreover,while a computer storage medium is not a propagated signal, a computerstorage medium can be a source or destination of computer programinstructions encoded in an artificially-generated propagated signal. Thecomputer storage medium can also be, or be included in, one or moreseparate physical components or media (e.g., multiple CDs, disks, orother storage devices).

The operations described in this specification can be implemented asoperations performed by a data processing apparatus on data stored onone or more computer-readable storage devices or received from othersources.

The term “data processing apparatus” encompasses all kinds of apparatus,devices, and machines for processing data, including by way of example aprogrammable processor, a computer, a system on a chip, or multipleones, or combinations, of the foregoing The apparatus can includespecial purpose logic circuitry, e.g., an FPGA (field programmable gatearray) or an ASIC (application-specific integrated circuit). Theapparatus can also include, in addition to hardware, code that createsan execution environment for the computer program in question, e.g.,code that constitutes processor firmware, a protocol stack, a databasemanagement system, an operating system, a cross-platform runtimeenvironment, a virtual machine, or a combination of one or more of them.The apparatus and execution environment can realize various differentcomputing model infrastructures, such as web services, distributedcomputing and grid computing infrastructures.

A computer program (also known as a program, software, softwareapplication, script, or code) can be written in any form of programminglanguage, including compiled or interpreted languages, declarative orprocedural languages, and it can be deployed in any form, including as astand-alone program or as a module, component, subroutine, object, orother unit suitable for use in a computing environment. A computerprogram may, but need not, correspond to a file in a file system. Aprogram can be stored in a portion of a file that holds other programsor data (e.g., one or more scripts stored in a markup languagedocument), in a single file dedicated to the program in question, or inmultiple coordinated files (e.g., files that store one or more modules,sub-programs, or portions of code). A computer program can be deployedto be executed on one computer or on multiple computers that are locatedat one site or distributed across multiple sites and interconnected by acommunication network.

The processes and logic flows described in this specification can beperformed by one or more programmable processors executing one or morecomputer programs to perform actions by operating on input data andgenerating output. The processes and logic flows can also be performedby, and apparatus can also be implemented as, special purpose logiccircuitry, e.g., an FPGA (field programmable gate array) or an ASIC(application-specific integrated circuit).

Processors suitable for the execution of a computer program include, byway of example, both general and special purpose microprocessors, andany one or more processors of any kind of digital computer. Generally, aprocessor will receive instructions and data from a read-only memory ora random access memory or both. The essential elements of a computer area processor for performing actions in accordance with instructions andone or more memory devices for storing instructions and data. Generally,a computer will also include, or be operatively coupled to receive datafrom or transfer data to, or both, one or more mass storage devices forstoring data, e.g., magnetic, magneto-optical disks, or optical disks.However, a computer need not have such devices. Moreover, a computer canbe embedded in another device, e.g., a mobile telephone, a personaldigital assistant (PDA), a mobile audio or video player, a game console,a Global Positioning System (GPS) receiver, or a portable storage device(e.g., a universal serial bus (USB) flash drive), to name just a few.Devices suitable for storing computer program instructions and datainclude all forms of non-volatile memory, media and memory devices,including by way of example semiconductor memory devices, e.g., EPROM,EEPROM, and flash memory devices; magnetic disks, e.g., internal harddisks or removable disks; magneto-optical disks; and CD-ROM and DVD-ROMdisks. The processor and the memory can be supplemented by, orincorporated in, special purpose logic circuitry.

To provide for interaction with a user, embodiments of the subjectmatter described in this specification can be implemented on a computerhaving a display device, e.g., a CRT (cathode ray tube) or LCD (liquidcrystal display) monitor, for displaying information to the user and akeyboard and a pointing device, e.g., a mouse or a trackball, by whichthe user can provide input to the computer. Other kinds of devices canbe used to provide for interaction with a user as well; for example,feedback provided to the user can be any form of sensory feedback, e.g.,visual feedback, auditory feedback, or tactile feedback; and input fromthe user can be received in any form, including acoustic, speech, ortactile input. In addition, a computer can interact with a user bysending documents to and receiving documents from a device that is usedby the user; for example, by sending web pages to a web browser on auser's client device in response to requests received from the webbrowser.

Embodiments of the subject matter described in this specification can beimplemented in a computing system that includes a back-end component,e.g., as a data server, or that includes a middleware component, e.g.,an application server, or that includes a front-end component, e.g., aclient computer having a graphical user interface or a Web browserthrough which a user can interact with an embodiment of the subjectmatter described in this specification, or any combination of one ormore such back-end, middleware, or front-end components. The componentsof the system can be interconnected by any form or medium of digitaldata communication, e.g., a communication network. Examples ofcommunication networks include a local area network (“LAN”) and a widearea network (“WAN”), an inter-network (e.g., the Internet), andpeer-to-peer networks (e.g., ad hoc peer-to-peer networks).

The computing system can include clients and servers. A client andserver are generally remote from each other and typically interactthrough a communication network. The relationship of client and serverarises by virtue of computer programs running on the respectivecomputers and having a client-server relationship to each other. In someimplementations, a server transmits data (e.g., an HTML page) to aclient device (e.g., for purposes of displaying data to and receivinguser input from a user interacting with the client device). Datagenerated at the client device (e.g., a result of the user interaction)can be received from the client device at the server.

While this specification contains many specific implementation details,these should not be construed as limitations on the scope of anyinventions or of what may be claimed, but rather as descriptions offeatures specific to particular implementations of particularinventions. Certain features that are described in this specification inthe context of separate embodiments can also be implemented incombination in a single embodiment. Conversely, various features thatare described in the context of a single embodiment can also beimplemented in multiple embodiments separately or in any suitablesubcombination. Moreover, although features may be described above asacting in certain combinations and even initially claimed as such, oneor more features from a claimed combination can in some cases be excisedfrom the combination, and the claimed combination may be directed to asubcombination or variation of a subcombination.

Similarly, while operations are depicted in the drawings in a particularorder, this should not be understood as requiring that such operationsbe performed in the particular order shown or in sequential order, orthat all illustrated operations be performed, to achieve desirableresults. In certain circumstances, multitasking and parallel processingmay be advantageous. Moreover, the separation of various systemcomponents in the implementations described above should not beunderstood as requiring such separation in all implementations, and itshould be understood that the described program components and systemscan generally be integrated together in a single software product orpackaged into multiple software products.

Thus, particular implementations of the subject matter have beendescribed. Other implementations are within the scope of the followingclaims. In some cases, the actions recited in the claims can beperformed in a different order and still achieve desirable results. Inaddition, the processes depicted in the accompanying figures do notnecessarily require the particular order shown, or sequential order, toachieve desirable results. In certain implementations, multitasking andparallel processing may be advantageous.

In some implementations, the systems and techniques disclosed in thisspecification can controllably manage multiple instances of a mediaplayer program to optimize the player's performance and to keepcomputing resources within given limits. The disclosed methods includeestablishing a priority sequence based on logic embedded within themedia player program. The media player program running inside a browserprogram can manage its own computing resources rather than having thebrowser program control the computing resources needed to run multipleinstances. The priority sequence can be reestablished/changed as newfactors may be introduced. For example in some implementations, tabpriority can be added to the established priority sequence if thebrowser program that hosts the media player program supports tabs.

In some implementations, the actions taken to reduce memory consumption,processor usage and battery power, may vary over time. In some cases, aninstance manager can suspend an instance rather than shut it down. Insome other cases, the instance manager may switch at least a portion ofthe instances of the media player to a low resources state (e.g., one ormore of player instances my be suspended when a backlight of a mobiledevice is turned to low or off.) In some implementations, a memorymanager and an instance manager can synchronously release computerresources from the multiple active and inactive instances of a mediaplayer program for optimizing the player's performance and for keepingcomputing resources within given limits. In a multiple processenvironment, inter-process messaging can be added to logic executed byan instance manager to perform the methods disclosed in thisspecification.

1. A method comprising: monitoring consumption of computing resources ofmultiple running instances of a media player program to renderrespective media content in a graphical user interface of a computingdevice, the graphical user interface associated with an additionalprogram configured to render additional content, different from themedia content, to the graphical user interface; upon determining that arequested increase in computer resources consumption of the media playerprogram would cause the computer resources consumption of the mediaplayer program to exceed a first predetermined level, identifyinginstances from among the multiple running instances for immediatereduction of respective portions of the computing resources consumption,flagging other instances from among the multiple running instances forsubsequent reduction of respective other portions of the computingresources consumption, and instructing the identified instances and theflagged instances to reduce corresponding portions of the computingresources consumption; and upon determining that the consumption of thecomputer resources, after accounting for the instructed reductions andfor the requested increase, is above the first predetermined level,selecting one or more of the multiple running instances for shut down,wherein a new consumption of the computing resources of one or moreremaining running instances of the media player program after shuttingdown the selected instances would be below the first predeterminedlevel, and wherein said selecting is performed according to one or morerules designed to maximize a number of presentations of the respectivemedia content rendered in the graphical user interface.
 2. The method ofclaim 1, further comprising shutting down the selected one or moreinstances, such that the new computing resources consumption is belowthe first predetermined level.
 3. The method of claim 2, furthercomprises determining that the consumption of the computer resources,after accounting for the instructed reductions and for the requestedincrease, is below a second predetermined level, wherein said shuttingdown comprises sequentially shutting down one instance at a time fromthe selected instances until the new computing resources consumption isbelow the first predetermined level.
 4. The method of claim 1, wherein:said selecting comprises: (i) determining paused instances of the mediaplayer program that are loaded in background, and selecting thedetermined instances, wherein the background includes portions of thegraphical user interface not visible on a display screen; then (ii)determining un-paused instances of the media player program running inthe background, and selecting the determined instances; then (iii)determining priority instances of the media player program running inthe background, and selecting the determined instances, wherein apriority instance of the media player has a priority assigned by theadditional program; then (iv) determining a focus instance of the mediaplayer program running in the background, and selecting the determinedinstance, wherein the focus instance represents an instance of the mediaplayer program which has received most recently an instruction via thegraphical user interface; then (v) determining helper instances of themedia player program running in the background, and selecting thedetermined instances, wherein the helper instances are configured toassist said running of other instances from the multiple instances; then(vi) determining paused instances of the media player program that areloaded in foreground, and selecting the determined instances, whereinthe foreground includes portions of the graphical user interface beingvisible; then (vii) determining un-paused instances of the media playerprogram running in the foreground, and selecting the determinedinstances; then (viii) determining priority instances of the mediaplayer program running in the foreground, and selecting the determinedinstances; then (ix) determining a focus instance of the media playerprogram running in the foreground, and selecting the determinedinstance; then (x) determining helper instances of the media playerprogram running in the foreground, and selecting the determinedinstances; and performing said sequentially shutting down one instanceat a time in order of instance selection.
 5. The method of claim 1,wherein said shutting down comprises: presenting graphical indicationsof a portion of the shutdown instances.
 6. The method of claim 5,wherein said presenting graphical indications comprises: displaying aproxy icon in place of a shutdown instance of the media player program.7. The method of claim 1, wherein said shutting down further comprises:displaying a click-to-play icon of a shut-down instance.
 8. The methodof claim 1, wherein the additional program is a browser.
 9. A dataprocessing system comprising: a data storage device to store one or morerules for managing consumption of computing resources by multiplerunning instances of a media player program configured to renderrespective media content in a graphical user interface of the dataprocessing system; the graphical user interface being associated with anadditional program configured to render additional content, differentfrom the media content, to the graphical user interface; and one or morehardware processors communicatively coupled with the data storage deviceand configured to perform operations comprising: monitoring theconsumption of computing resources of the multiple running instances ofthe media player program; upon determining that a requested increase incomputing resources consumption of the media player would cause thecomputing resources consumption of the media player to exceed a firstpredetermined level, identifying instances from among the multiplerunning instances for immediate reduction of respective portions of thecomputing resources consumption, flagging other instances from among themultiple running instances for subsequent reduction of respective otherportions of the computing resources consumption, and instructing theidentified instances and the flagged instances to reduce correspondingportions of the computing resources consumption; and upon determiningthat the consumption of the computer resources, after accounting for theinstructed reductions and for the requested increase, is above the firstpredetermined level, selecting one or more of the multiple runninginstances for shut down, wherein a new consumption of the computingresources of one or more remaining running instances of the media playerprogram after shutting down the selected instances would be below thefirst predetermined level, and wherein the selecting operation isperformed according to the stored one or more rules.
 10. The system ofclaim 9, wherein the operations further comprise shutting down theselected one or more instances, such that the new computing resourcesconsumption is below the first predetermined level.
 11. The system ofclaim 10, wherein the operations further comprise determining that theconsumption of the computer resources, after accounting for theinstructed reductions and for the requested increase, is below a secondpredetermined level, and said shutting down comprises sequentiallyshutting down one instance at a time from the selected instances untilthe new computing resources consumption is below the first predeterminedlevel.
 12. The system of claim 9, wherein said selecting operationcomprises (i) determining paused instances of the media player programthat are loaded in background, and selecting the determined instances,wherein the background includes portions of the graphical user interfacenot visible on a display screen; then (ii) determining un-pausedinstances of the media player program running in the background, andselecting the determined instances; then (iii) determining priorityinstances of the media player program running in the background, andselecting the determined instances, wherein a priority instance of themedia player has a priority assigned by the additional program; then(iv) determining a focus instance of the media player program running inthe background, and selecting the determined instance, wherein the focusinstance represents an instance of the media player program which hasreceived most recently an instruction via the graphical user interface;then (v) determining helper instances of the media player programrunning in the background, and selecting the determined instances,wherein the helper instances are configured to assist running of otherinstances from the multiple instances; then (vi) determining pausedinstances of the media player program that are loaded in foreground, andselecting the determined instances, wherein the foreground includesportions of the graphical user interface being visible; then (vii)determining un-paused instances of the media player program running inthe foreground, and selecting the determined instances; then (viii)determining priority instances of the media player program running inthe foreground, and selecting the determined instances; then (ix)determining a focus instance of the media player program running in theforeground, and selecting the determined instance; then (x) determininghelper instances of the media player program running in the foreground,and selecting the determined instances; and wherein the one or morehardware processors are further configured to perform operationscomprising carrying out said sequentially shutting down one instance ata time in order of instance selection.
 13. The system of claim 9,wherein said shutting down operation comprises displaying correspondingproxy icons in place of at least a portion of the shutdown instances.14. The system of claim 9, wherein the additional program is a browser.15. The system of claim 9, wherein the computing resources comprise oneor more of (i) memory available to the multiple running instances of themedia player program, and (ii) power of the one or more hardwareprocessors consumed by the multiple running instances of the mediaplayer program.
 16. A computer storage medium encoded with a computerprogram, the program comprising instructions that when executed by dataprocessing apparatus cause the data processing apparatus to performoperations comprising: monitoring consumption of computing resources ofmultiple running instances of a media player program to renderrespective media content in a graphical user interface of a mobiledevice, the graphical user interface associated with an additionalprogram configured to render additional content, different from themedia content, to the graphical user interface; instructing a firstgroup of instances from among the multiple running instances to reducerespective portions of the computing resources consumption in responseto determining that a requested increase in computing resourcesconsumption of the media player program would cause the computerresources consumption of the media player program to exceed a firstpredetermined level, and flagging other instances from among themultiple running instances to subsequently reduce corresponding computerresources consumption; allocating the requested increase in computerresources consumption in response to determining that the computerresources consumption would be less than the first predetermined levelafter accounting for the instructed reduction of the first group ofinstances; selecting one or more instances to be shut down among themultiple instances in response to determining that a new computerresources consumption, after accounting for the instructed reductions ofthe first group of instances and of the flagged instances and for theallocation, is greater that the first predetermined level and smallerthan a second predetermined level; and shutting down at least a portionof the selected instances to bring the computing resources consumptionbelow the first predetermined level.
 17. The computer storage medium ofclaim 16, wherein the operation of shutting down comprises sequentiallyshutting down one instance at a time from the multiple instances untilthe computing resources consumption is below the first predeterminedlevel.
 18. The computer storage medium of claim 17, wherein theoperation of selecting is performed according with one or more rulesdesigned to maximize a number of presentations of the respective mediacontent rendered in the graphical user interface, such that theoperation of selecting comprises: (i) determining paused instances ofthe media player program that are loaded in background, and selectingthe determined instances, wherein the background includes portions ofthe graphical user interface not visible on a display screen; then (ii)determining un-paused instances of the media player program running inthe background, and selecting the determined instances; then (iii)determining priority instances of the media player program running inthe background, and selecting the determined instances, wherein apriority instance of the media player has a priority assigned by theadditional program; then (iv) determining a focus instance of the mediaplayer program running in the background, and selecting the determinedinstance, wherein the focus instance represents an instance of the mediaplayer program which has received most recently an instruction via thegraphical user interface; then (v) determining helper instances of themedia player program running in the background, and selecting thedetermined instances, wherein the helper instances are configured toassist said running of other instances from the multiple instances; then(vi) determining paused instances of the media player program that areloaded in foreground, and selecting the determined instances, whereinthe foreground includes portions of the graphical user interface beingvisible; then (vii) determining un-paused instances of the media playerprogram running in the foreground, and selecting the determinedinstances; then (viii) determining priority instances of the mediaplayer program running in the foreground, and selecting the determinedinstances; then (ix) determining a focus instance of the media playerprogram running in the foreground, and selecting the determinedinstance; then (x) determining helper instances of the media playerprogram running in the foreground, and selecting the determinedinstances; and performing said sequentially shutting down one instanceat a time in order of instance selection.
 19. The computer storagemedium of claim 17, wherein the additional program is a browser.
 20. Thecomputer storage medium of claim 16, wherein the operation of shuttingdown comprises presenting graphical indications of a portion of theshutdown instances.
 21. The computer storage medium of claim 20, whereinthe operation of presenting graphical indications comprises displaying aproxy icon in place of a shutdown instance of the media player program.22. The computer storage medium of claim 20, wherein the operation ofshutting down comprises displaying a click-to-play icon of a shut-downinstance.